/*
 * Utils.cpp
 *
 *  Created on: Oct 1, 2009
 *      Author: karthik
 */

#include<vector>
#include "Utils.h"

using namespace std;


// Function for splitting a string using a delimiter
void StringSplit(string str, string delim, vector<string>& results)
{
	int cutAt;
	while( (cutAt = ((int) str.find_first_of(delim))) != ((int)str.npos) )
	{
		if(cutAt > 0)
		{
			results.push_back(str.substr(0,cutAt));
		}
		str = str.substr(cutAt+1);
	}
	if(str.length() > 0)
	{
		results.push_back(str);
	}
}

// Function for printing an object of type vector<double>
void printVofDouble(const vector<double>& vect){
	for (int i=0;i<(int) vect.size();i++){
		cout<<vect[i]<<", ";
	}
	cout<<endl;
}

//	Function for printing an Array2D object
void printArray2D(const Array2D<double>& X){
	for (int i=0;i<X.dim1();i++){
		for (int j=0;j<X.dim2();j++){
			cout<<X[i][j]<<", ";
		}
		cout<<"\n ";
	}
}


